package genosAgape.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import genosAgape.conexao.Conexao;
import genosAgape.util.interfaces.Crud;
import genosAgape.vo.Die;
import genosAgape.vo.Pontuacao;

public class PontuacaoDAO implements Crud {
	
	private Pontuacao pontuacao;
	
	@Override
	public void inserir(Object args) throws Exception {
		Connection conexao = Conexao.getConnection();
		conexao.setAutoCommit(false);
		PreparedStatement pstmt = null;
		String sqlInsert = "INSERT INTO ga.pontuacao_die(codigo_die, dia, mes, ano) VALUES (?, ?, ?, ?)";
		try {
			pstmt = conexao.prepareStatement(sqlInsert);
			this.pontuacao = (Pontuacao) args;
			persisteObjetoDie(this.pontuacao, pstmt);
			conexao.commit();
		} catch (SQLException e) {
			conexao.rollback();
			System.out.println("\n*-----*\nErro, PontuacaoDao.inserir()\n*-----*\n");
			e.printStackTrace();
			throw new SQLException(e);
		} finally {
			conexao.close();
			pstmt.close();
		}
	}

	private void persisteObjetoDie(Pontuacao pontuacao, PreparedStatement pstmt) throws SQLException {
		pstmt.setInt(1, pontuacao.getCodigo_die());
		pstmt.setInt(2, pontuacao.getDia());
		pstmt.setInt(3, pontuacao.getMes());
		pstmt.setInt(4, pontuacao.getAno());
		pstmt.executeUpdate();
	}

	@Override
	public void remover(Object args) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void alterar(Object args) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List listar(Object arg) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List listarTodos() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List listarLinha(List<Object> args) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}



}
